import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import PropTypes from 'prop-types'
import './index.scss'

// https://ninghao.net/files/styles/course_cover/public/showcase/flutter-bloc-showcase.jpg?itok=706zNDkY

export default class XList extends Component {

    static propTypes = {
        data: PropTypes.array,
        title: PropTypes.string,
        isList: PropTypes.string,
    }

    static defaultProps = {
        data: [],
        title: '',
        isList: true
    }

    render() {

        const { title, figcaption, image, isList } = this.props

        return (
            <View className='list'>
                {
                    isList
                        ?
                        <View className='header'>
                            <View className='title'>
                                <View className='icon' />
                                <Text>{title}</Text>
                            </View>
                        </View>
                        :
                        <View className='item'>
                            <Text>赞助商</Text>
                            <Text>H5工坊</Text>
                        </View>
                }
                {
                    isList
                    &&
                    <View className='figure'>
                        {figcaption && <Text className='figcaption'>{figcaption}</Text>}
                        {image && <Image src={image} className='image' mode='widthFix' />}
                    </View>
                }
            </View>
        )
    }
}